<div class="row">
<section>
<form class="form-horizontal" id="form_adminmain" action="${request.contextPath}/manage/resource/adminmain"
	data-fv-message="This value is not valid"
	data-fv-icon-valid="glyphicon glyphicon-ok"
	data-fv-icon-invalid="glyphicon glyphicon-remove"
	data-fv-icon-validating="glyphicon glyphicon-refresh">
  <h3 class="m-t-none m-b">管理员</h3>
    	<div class="form-group">
    		<label class="col-lg-2 control-label">名称</label>
          <div class="col-lg-10">
          	<input name="name" type="text" placeholder="管理员显示名称" class="form-control" value="${data.name}"
          	required data-fv-notempty-message="名称不可为空"
          	data-fv-stringlength="true" data-fv-stringlength-max="10" data-fv-stringlength-message="名称长度不得超过10个字符"/>
          </div>
       </div>
       <div class="form-group"><label class="col-lg-2 control-label">帐号</label>
           <div class="col-lg-10">
           		<input ${(data.id??)?string('readonly', '')} name="account" type="text" placeholder="管理员登录后台帐号" class="form-control" value="${data.account}"
           		required data-fv-notempty-message="帐号不可为空"
           		pattern="^[a-zA-Z-]+$" data-fv-regexp-message="角色编码必须为英文字母不区分大小写"
           		data-fv-stringlength="true" data-fv-stringlength-max="20" data-fv-stringlength-message="帐号长度不得超过20个字符"
           		/>
           </div>
       </div>
       [#if !(data.id??)]
      <div class="form-group"><label class="col-lg-2 control-label">密码</label>
           <div class="col-lg-10">
           		<input name="password" type="text" placeholder="管理员登录后台密码" class="form-control" value=""
           		required data-fv-notempty-message="密码不可为空"
           		pattern="^[a-zA-Z-]+$" data-fv-regexp-message="密码必须为英文字母、数字组成不区分大小写"
           		/>
           </div>
       </div>
       [/#if]
       <div class="form-group"><label class="col-lg-2 control-label">手机号码</label>
           <div class="col-lg-10">
           	<input name="phone_number" type="text" placeholder="手机号码" class="form-control" value="${data.phone_number}"
           		required data-fv-notempty-message="手机号码不可为空"
           		pattern="1[345789]\d{9}" data-fv-regexp-message="手机号码格式填写错误"
           		data-fv-stringlength="true" data-fv-stringlength-max="11" data-fv-stringlength-message="手机号码长度超过11位"
           		/>
           </div>
       </div>
       <div class="form-group"><label class="col-lg-2 control-label">启用状态</label>
           <div class="col-lg-10">
           		<label class="checkbox-inline i-checks"><input type="radio" [#if data.is_activity != 2]checked[/#if]  value="1" name="is_activity"/>&nbsp;&nbsp;启用</label>
           		<label class="checkbox-inline i-checks"><input type="radio" [#if data.is_activity == 2]checked[/#if]  value="2" name="is_activity" />&nbsp;&nbsp;作废</label>
           </div>
       </div>
       <div class="form-group">
       		<label class="col-lg-2 control-label">选择角色</label>
	       	 <div class="col-lg-10">
	       	 	[#list roles as role]
	       			<label class="checkbox-inline i-checks">
	       				<input type="checkbox" [#if data.roles??][#list data.roles as r][#if r.code == role.code]checked[/#if][/#list][/#if] value="${role.code}" name="roleCodes"/>&nbsp;&nbsp;${role.name}
	       			</label>
	       	 	[/#list]
	       	 </div>
       </div>
       <div class="form-group">
          <div class="col-sm-offset-9 col-lg-10">
          	  <input value="${data.id}" name="id" type="hidden" />
              <a href="javascript:void(0);" class="btn btn-white" data-dismiss="modal" aria-hidden="true">取消</a>
              <a href="javascript:void(0);" class="btn btn-primary" onclick="$('#form_adminmain').submit();" >保存</a>
          </div>
      </div>
</form>
</section>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#form_adminmain')
	.formValidation()
	.on('success.form.fv', function(e){
		// Prevent form submission
        e.preventDefault();
     // Get the fom instance
        var $form = $(e.target);
        // Use Ajax to submit form data
      $.post($form.attr('action'), $form.serialize(), function(result) {
           if(result.state == 1){
        	  $.get("${request.contextPath}/manage/resource/admintable", function(data){
       				$("#div_table_container").html(data);
       		  });	
        	  $('#form_adminmain').formValidation('resetForm', true);
        	  $('#modal-adminmain-form').modal('hide');
           } else {
        	   toastr.warning(result.message);
           } 
        }, 'json'); 
	});
	
	$('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    });
	
	
});
</script>